













#ifndef _fc_h_
#define _fc_h_


/* MIXER VERSION */
#define MIXER_CFG_QUAD_T    1
#define MIXER_CFG_QUAD_X    2
#define MIXER_CFG_HEX_T     3
#define MIXER_CFG_OKTO_T    4

/****** macro functions ******/
#define LIMIT_MIN(value, min) {if(value < min) value = min;}
#define LIMIT_MAX(value, max) {if(value > max) value = max;}
#define LIMIT_MIN_MAX(value, min, max) {if(value < min) value = min; else if(value > max) value = max;}
#define CHECK_MIN_MAX(wert,min,max) {if(wert < min) wert = min; else if(wert > max) wert = max;}

/****** rc channel definition ******/
#define K_ROLL    0
#define K_NICK    1
#define K_GAS     2
#define K_GIER    3
#define K_MODE   4
#define K_POTI2   5
#define K_POTI3   6
#define K_POTI4   7

#define ACC_AMPLIFY     6
#define FAKTOR_P        1
#define FAKTOR_I        0.0001
#define STICK_GAIN      4

/* looping threshold and delay */
#define LOOPING_THRESHOLD  110
#define LOOPING_DELAY      100

//#define LOOPING_DESIRE_STICK 4096 /* 4096*4 */
#define LOOPING_STICK_AMP  1
#define LOOPING_GAS_LIMIT  150 // [-128, +128] + 120 = [0, 250]




typedef struct    // 61 bytes
{
  // joystick parameter
  unsigned char Stick_P;                // Wert : 1-6
  unsigned char Stick_D;                // Wert : 0-64  
  unsigned char Gier_P;                 // Wert : 1-20 

  // attitude calculation parameter
  unsigned char GyroAccFaktor;          // Wert : 1-64  
  unsigned char GyroAccAbgleich;        // 1/k  (Koppel_ACC_Wirkung)
  unsigned char Driftkomp;
  unsigned char AchsKopplung1;          // Wert: 0-250  Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung)
  unsigned char AchsKopplung2;          // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
  unsigned char KompassWirkung;         // Wert : 0-32
  unsigned char CouplingYawCorrection;  // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
  
  // attitude control parameter
  unsigned char Gyro_P;                 // Wert : 10-250
  unsigned char Gyro_I;                 // Wert : 0-250
  unsigned char Gyro_D;                 // Wert : 0-250
  unsigned char I_Faktor;               // Wert : 0-250
  unsigned char Gyro_Gier_P;            // Wert : 10-250
  unsigned char Gyro_Gier_I;            // Wert : 0-250    
  unsigned char DynamicStability;
  
  char Name[12];
}mk_param_struct;

typedef struct
{
  char Name[12];
  signed char Motor[16][4];             // 16 motor maximum  
}mixer_struct;


extern void flight_control(void);




#endif